<template>
  <div>
    <ul>
      <li>
       
        <van-image v-if="avtar"
        round
        width="3rem"
        height="3rem"
        :src="avtar"
      />
      </li>
    </ul>
    <p v-if="email">欢迎用户：{{email}} <br> <a href="#" @click="logout">退出登录</a></p>
    <ul>
        <li><a href="/">首页</a></li>
        <li><a href="/register">注册</a> </li>
        <li><a href="/login">登录</a></li>
        <li><a href="/active">激活</a> </li>
        <li><a href="/setting">个人设置</a></li>
        <li><a href="/file">我的文件</a></li>
        <li><a href="/node">账号授权</a></li>
        <li><a href="/rolenode">角色授权</a></li>
        <li><a href="/user">用户管理</a></li>
        <li><a href="/role">角色管理</a></li>
    </ul>
  </div>
</template>

<script>
export default {

  data(){
    return{
     email:'',
     avtar:'',
    }
  },
  methods:{
    // 退出登录
    logout:function(){
      localStorage.removeItem('token')
      localStorage.removeItem('email')
      this.email = ''
      window.location.href = '/login'
      // this.$router.push('/login')
    },
    // 获取用户头像信息
    userinfo:function(){
          //获取用户头像
    this.myaxios(this.baseURL+'user_info','get').then(resp=>{
      console.log('获取头像',resp)
      if(resp.errcode == 0){
         if(resp.avtar[0] == '.'){
        this.avtar = this.baseURL + resp.avtar
      }else{
        this.avtar = resp.avtar

      }
      localStorage.setItem('avtar',this.avtar) 
      localStorage.setItem('cate',resp.cate)
      }
     
      // localStorage.setItem('avtar',this.avtar)
     

    })
    }
   
  },
  mounted(){
    
  },
  created(){
    if(localStorage.getItem('token')!=null){
      this.email = localStorage.getItem('email')
      this.userinfo()
    }else{
      this.email = ''
    }


  }
    

}
</script>

<style>

</style>